package com.cw.demo.mybatisplus.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.cw.demo.mybatisplus.model.UserDo;
import com.cw.demo.mybatisplus.service.IUserService;

import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 * 用户信息 前端控制器
 * </p>
 *
 * @author chenw
 * @since 2021-01-15
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private IUserService iUserService;
    @GetMapping("/findById")
    public UserDo findById(Long id){
        UserDo userDo = iUserService.getById(id);
        log.info(JSON.toJSONString(userDo));
        return userDo;
    }
    @GetMapping("/findAll")
    public List<UserDo> findAll(){
        List<UserDo> userDos = iUserService.findAllUser();
        log.info(JSON.toJSONString(userDos));
        return userDos;
    }
}
